home *** CD-ROM | disk | FTP | other *** search
- Path: news.acns.nwu.edu!aragorn203
- From: llong@nwu.edu (Laurie Long)
- Newsgroups: comp.lang.c
- Subject: Re: Beginer C please help me
- Date: Thu, 28 Mar 96 18:25:57 GMT
- Organization: Northwestern University, Evanston, IL. USA
- Message-ID: <4jeljl$8cg_001@nuts.nwu.edu>
- References: <DoLCFx.B7x.0.bloor@torfree.net> <4iq6uc$evq@daryl.scsn.net> <4irjqa$jtn@winx03.informatik.uni-wuerzburg.de>
- NNTP-Posting-Host: aragorn203.nuts.nwu.edu
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4irjqa$jtn@winx03.informatik.uni-wuerzburg.de>,
- schoof@informatik.uni-wuerzburg.de (Jochen Schoof) wrote:
- >Scott Shrader (shrader@scsn.net) wrote:
- >: In article <DoLCFx.B7x.0.bloor@torfree.net>, bz786@torfree.net says...
- >: >
- >: >This may be a stupid mistake but "please help" me.
- >: >Thank you very much.
- >: >
- >: >#include <stdio.h>
- >: >#include <math.h>
- >: >main ()
- >: >{
- >: >float n;
- >: >n=(9/5);
- >: >printf ("n= %1.3f\n", n);
- >: >}
- >: >I have complied and run the programme & I got the answer n=1.000
- >: >but Iam supposed to get answer 1.8.
- >: >Why I got this answer?
- >: >--
- >:What you are asking the program to do is convert an int value (9/5 = 1) to a
- float. You need to type cast either the dividend or the divisor as a float.
-
-
- Laurie Long
- Northwestern University, Evanston, IL. USA
- llong@nwu.edu
-